const { defineConfig } = require('@vue/cli-service');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = defineConfig({
  outputDir: './ZhihuiCloudIncubator', // 设置打包输出目录
  publicPath: './', // 设置公共路径
  productionSourceMap: false, // 禁用 Source Maps
  configureWebpack: {
    resolve: {
      fallback: {
        timers: require.resolve('timers-browserify')
      }
    },
    optimization: {
      minimize: true, // 启用代码压缩
      minimizer: [
        new TerserPlugin({
          terserOptions: {
            compress: {
              drop_console: true, // 删除 console.log
              drop_debugger: true, // 删除 debugger
              pure_funcs: ['console.info', 'console.debug', 'console.warn'], // 删除特定的 console 函数
            },
            output: {
              comments: false, // 删除所有注释
            },
          },
          extractComments: false, // 禁用注释提取
        }),
      ],
    },
  }
});
